package com.lhj.xxsc.order.web;

import com.alipay.api.AlipayApiException;
import com.lhj.xxsc.order.config.AlipayTemplate;
import com.lhj.xxsc.order.service.OrderService;
import com.lhj.xxsc.order.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 罗惠江
 * @version 1.0
 * @email 1511619294@qq.com
 * @date 2021/1/8 16:15
 */
@Controller
public class PayWebController {
	@Autowired
	AlipayTemplate alipayTemplate;
	@Autowired
	OrderService orderService;

	@ResponseBody
	@GetMapping(value = "/payOrder", produces = "text/html")
	public String payOrder(@RequestParam("orderSn") String orderSn) throws AlipayApiException {
		PayVo payVo = orderService.getOrderPay(orderSn);

		String pays = alipayTemplate.pay(payVo);
		System.out.println(pays);
		return pays;
	}
}
